// url=='urlPath'
export default {
  bind(el, binding) {
    el.addEventListener('click', () => {
      console.log(binding.value)
      if (binding.value.length == 0 || !binding.value) return
      let pictrues = binding.value

      if (pictrues[0].urlPath) {
        let a = document.createElement('a')
        for (let i = 0; i < pictrues.length; i++) {
          let url = JSON.parse(JSON.stringify(pictrues[i].urlPath))
          fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
            a.href = URL.createObjectURL(blob)
            console.log(a.href)
            a.download = pictrues[i].fileName // 下载文件的名字
            //   // a.download = url.split('/')[url.split('/').length -1] //  // 下载文件的名字
            document.body.appendChild(a)
            a.click()
          })
        }
      } else {
        let a = document.createElement('a')
        for (let i = 0; i < pictrues.length; i++) {
          a.href = pictrues[i]
          a.download = i // 下载文件的名字
          document.body.appendChild(a)
          a.click()
        }
      }
    })
  }
}